<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let random = Math.floor(Math.random() * 21)
        let flag = true

        for (let i = 1; i <= 5; i++) {
            let num = +prompt(`请输入你猜测的数字`)
            if (num > random) {
                alert(`猜大了`)
            }
            else if (num < random) {
                alert(`猜小了`)
            }
            else {
                flag = false
                alert(`恭喜你猜对了`)
                break
            }
        }
        if (flag) {
            document.write(`你的次数用完通关失败`)
        }
    </script>
</body>

</html>